import tensorflow as tf
import numpy as np
np.random.seed(1)

train_features = np.random.randint(0, 10, (10, 2))
train_labels = [1]*5 + [0]*5
np.random.shuffle(train_labels)
train_labels = np.array(train_labels)
print(train_features)
print(train_labels)


dataset = tf.data.Dataset.from_tensor_slices((train_features, train_labels))
dataset = dataset.repeat(count=1).batch(batch_size=3)
iterator = dataset.make_initializable_iterator()
# (bx, by) = iterator.get_next()


with tf.Session() as sess:
	sess.run([iterator.initializer])
	batch = iterator.get_next()
	for i in range(4):
		bx, by = sess.run(batch)
		print(bx)
		print(by)

	# print(bx.eval(session=sess))

	# print(bx.eval(session=sess))    # 这个也不行
	# print(bx.eval(session=sess))
	# print(bx.eval(session=sess))
	# # print(by.eval(session=sess))
	# for i in range(100):
	# # 	pass
	# 	print(bx.eval(session=sess))
	# 	print(bx.eval(session=sess))
	# 	_ = sess.run([])


	# try:
	# 	for i in range(100):
	# 		# pass
	# 		print(bx)
	# 		print(by)
	# 		# print('bx: ', sess.run(bx))
	# 		# print('by: ', sess.run(by))
	# 		# print(bx.eval(session=sess).shape)
	# 		# print(by.eval(session=sess).shape)
	# except tf.errors.OutOfRangeError :
	# 	print("我靠")
